package com.ruoyi.web.controller.wx.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.HomeUser;
import com.ruoyi.system.domain.vo.HomeUserVO;
import com.ruoyi.system.domain.vo.HomeVO;
import com.ruoyi.system.domain.vo.SysListingInformationListVO;
import com.ruoyi.web.controller.wx.service.IWxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx/user")
public class WxUserController {

    @Autowired
    private IWxUserService wxUserService;


    /**
     * 用户详情
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public AjaxResult userDetail(@PathVariable Long id){
        HomeUser user = wxUserService.userDetail(id);
        return AjaxResult.success(user);
    }

    /**
     * 修改用户信息
     * @param homeUserVO
     * @return
     */
    @PostMapping("/updateUser")
    public AjaxResult updateDetail(@RequestBody HomeUserVO homeUserVO){
        wxUserService.updateDetail(homeUserVO);
        return AjaxResult.success();
    }

    /**
     * 获取用户浏览记录
     * @param id
     * @return
     */
    @GetMapping("/userHistory/{id}")
    public AjaxResult userHistory(@PathVariable Long id){
        List<SysListingInformationListVO> list=wxUserService.userHistory(id);
        return AjaxResult.success(list);
    }

    /**
     * 用户关注 取消关注
     * @param homeVO
     * @return
     */
    @PostMapping("/userAttention")
    public AjaxResult userAttention(@RequestBody HomeVO homeVO ){
        wxUserService.userAttention(homeVO);
        return AjaxResult.success();
    }

    /**
     * 用户关注列表
     * @param id
     * @return
     */
    @GetMapping("/attentionList/{id}")
    public AjaxResult attentionList(@PathVariable Long id){
        List<SysListingInformationListVO> list=wxUserService.attentionList(id);
        return AjaxResult.success(list);
    }

    /**
     * 批量删除我的收藏
     * @param homeVO
     * @return
     */
    @PostMapping("/deleteAttention")
    public AjaxResult deleteAttention(@RequestBody HomeVO homeVO){
        wxUserService.deleteAttention(homeVO);
        return AjaxResult.success();
    }

    /**
     * 我的发布
     * @return
     */
    @GetMapping("/myHome/{id}")
    public AjaxResult myHome(@PathVariable Long id){
        List<SysListingInformationListVO> list=wxUserService.myHome(id);
        return AjaxResult.success(list);
    }

    /**
     * 批量修改我的发布 将未出租改为已出租
     * @param homeVO
     * @return
     */
    @PostMapping("updateHome")
    public AjaxResult updateHome(@RequestBody HomeVO homeVO){
        wxUserService.updateHome(homeVO);
        return AjaxResult.success();
    }

    /**
     * 批量删除我的发布
     * @param homeVO
     * @return
     */
    @PostMapping("deleteHome")
    public AjaxResult deleteHome(@RequestBody HomeVO homeVO){
        wxUserService.deleteHome(homeVO);
        return AjaxResult.success();
    }
}
